import request from "@/request";

export function changePwd(oldPwd, newPwd, token) {
  return request({
    headers: {'Authorization': token},
    url: '/users/pwd',
    method: 'post',
    data: {
      oldPwd,
      newPwd
    }
  })
}

export function changeEmail(data, token) {
  return request({
    headers: {'Authorization': token},
    url: '/users/email',
    method: 'put',
    data
  })
}

export function updateUser(data, token) {
  return request({
    headers: {'Authorization': token},
    url: '/users/update',
    method: 'put',
    data: data
  })
}

export function accountExist(account) {
  return request({
    url: `/users/account/${account}`,
    method: 'get',
  })
}

export function emailExist(email) {
  return request({
    url: `/users/email/${email}`,
    method: 'get',
  })
}
